class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2025-07-09",
      revision: "1c08d6e575c13ef990a2265320bea09f8e209ac9"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_sequoia: "845171469451163a687b91b1039a68864e0e5fe0d24e66c4751a70f7c852c501"
    sha256 cellar: :any_skip_relocation, arm64_sonoma:  "b591899f2bf71774a084634e633112518b2fbb3680f027374c4af259b6abc902"
    sha256 cellar: :any_skip_relocation, arm64_ventura: "90dd622456b66281eb39da798d46733cb2f3b9ccc6ee1516ee2171c1bd3f8436"
    sha256 cellar: :any_skip_relocation, sonoma:        "6604fb66d52c324ff5e4ee7e35213eec1c65b0d196adb243d1c829e5312a0f60"
    sha256 cellar: :any_skip_relocation, ventura:       "bdc12dcd04fee46777c4c8ad901030b19ce1100d8cdc172d2d1ce7859822e253"
    sha256 cellar: :any_skip_relocation, arm64_linux:   "b59312a64fa073b2e96857f142e5eff0243c4f0340e16bbb402506260e3813e2"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "d57c5c381710e320fb5c31315c0ac226f3b7a25718bf2cadf8171e57078f37d5"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system bin/"searchsploit", "sendpage"
  end
end
